package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSupplierdesSpec;
import com.ruoyi.xh.service.IXhSupplierdesSpecService;

/**
 * 分类下规格Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "分类下规格Controller",value = "分类下规格Controller")
@RestController
@RequestMapping("/xh/supplierdesSpec")
public class XhSupplierdesSpecController extends BaseController {

    @Autowired
    private IXhSupplierdesSpecService xhSupplierdesSpecService;

    /**
     * 查询分类下规格列表
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdesSpec:list')")
    @GetMapping("/list")
    @ApiOperation("查询分类下规格列表")
    public TablePageDataInfo<XhSupplierdesSpec> list(XhSupplierdesSpec xhSupplierdesSpec) {
        return TablePageDataInfo.success(xhSupplierdesSpecService.selectXhSupplierdesSpecList(xhSupplierdesSpec));
    }

    /**
     * 获取分类下规格详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdesSpec:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取分类下规格详细信息")
    public CommentResult<XhSupplierdesSpec> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSupplierdesSpecService.selectXhSupplierdesSpecById(id));
    }

    /**
     * 新增分类下规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdesSpec:add')")
    @Log(title = "分类下规格", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增分类下规格")
    public CommentResult<XhSupplierdesSpec> add(@RequestBody XhSupplierdesSpec xhSupplierdesSpec) {
            xhSupplierdesSpecService.insertXhSupplierdesSpec(xhSupplierdesSpec);
        return CommentResult.success();
    }

    /**
     * 修改分类下规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdesSpec:edit')")
    @Log(title = "分类下规格", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改分类下规格")
    public CommentResult<XhSupplierdesSpec> edit(@RequestBody XhSupplierdesSpec xhSupplierdesSpec) {
            xhSupplierdesSpecService.updateXhSupplierdesSpec(xhSupplierdesSpec);
        return CommentResult.success();
    }

    /**
     * 删除分类下规格
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdesSpec:remove')")
    @Log(title = "分类下规格", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除分类下规格")
    public CommentResult<XhSupplierdesSpec> remove(@PathVariable Long[] ids) {
            xhSupplierdesSpecService.deleteXhSupplierdesSpecByIds(ids);
        return CommentResult.success();
    }
}
